/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SENSOR_SHAKE_CONTROL_MANAGER_H
#define SENSOR_SHAKE_CONTROL_MANAGER_H

#include "singleton.h"

namespace OHOS {
namespace Sensors {
struct ShakeControlAppInfo {
    std::string bundleName;
    std::string tokenId;
    int32_t userId;
};
const int32_t INVALID_USERID = 100;
class SensorShakeControlManager {
    DECLARE_DELAYED_SINGLETON(SensorShakeControlManager);
public:
    DISALLOW_COPY_AND_MOVE(SensorShakeControlManager);
    bool Init();
    void UpdateRegisterShakeSensorControlObserver();
    bool CheckAppIsNeedControl(const std::string &bundleName, const std::string &tokenId, const int32_t &userId);
    bool CheckAppInfoIsNeedModify(const std::string &bundleName, const std::string &tokenId, const int32_t &userId);
    int32_t GetCurrentUserId();

private:
    void InitShakeSensorControlAppInfos();
    int32_t UpdateCurrentUserId();
    int32_t RegisterShakeSensorControlObserver();
    int32_t UnregisterShakeSensorControlObserver();
    std::mutex shakeSensorControlAppInfoMutex_;
    std::vector<ShakeControlAppInfo> shakeSensorControlAppInfoList_;
    std::vector<ShakeControlAppInfo> shakeSensorNoControlAppInfoList_;
    std::atomic_int32_t currentUserId_ = INVALID_USERID;
};
#define SENSOR_SHAKE_CONTROL_MGR DelayedSingleton<SensorShakeControlManager>::GetInstance()
}  // namespace Sensors
}  // namespace OHOS
#endif  // SENSOR_SHAKE_CONTROL_MANAGER_H